﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using SharedLib.Network.Server;
using Lidgren.Network;
using Lidgren.Network.Xna;


namespace SharedLib.Engine
{
    public class Monster : Creature
    {
        public Monster()
        {
            this.Type = EntityType.Monster;
          
        }


        private Int32 sens = -1;
        private Int32 current = 0;
        public override void Update(GameTime gameTime)
        {
            this.Position += this.Velocity * ( gameTime.ElapsedGameTime.Milliseconds / 200f );
        }
        public override void  Update(long time)
        {

            float ratio = time / (float)Constants.UPDATE_RATIO;

            current += sens;


            this.Position += new Vector2(10f, 0) * sens *ratio;

            Rotation += 0.01f * ratio;
            if (Rotation > MathHelper.Pi * 2)
                Rotation -= MathHelper.Pi * 2;

            if ((current == -10) || (current == 10))
                sens = -sens;
        }
        public override void WriteData(NetOutgoingMessage outmsg)
        {
            base.WriteData(outmsg);
            outmsg.Write(this.ID);
            outmsg.Write(this.Name);
            outmsg.Write(this.Position);
            outmsg.Write(this.Rotation);
            outmsg.Write(this.HP);
            outmsg.Write(this.HPMAX);
            outmsg.Write(this.Mana);
            outmsg.Write(this.ManaMAX);
        }

        public override void ReadData(Lidgren.Network.NetIncomingMessage _msgBuffer)
        {
            base.ReadData(_msgBuffer);
        }
    }
}
